package com.wosai.medical.hospital.demo.service.impl;

import com.wosai.medical.hospital.demo.config.AppConfig;
import com.wosai.medical.hospital.demo.service.AppSignService;
import com.wosai.medical.hospital.demo.util.SignUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.annotation.Nonnull;
import java.io.Serializable;
import java.util.Map;

/**
 * App签名-服务接口实现
 *
 * @author yangyong
 * @version 1.0
 * @date 2019/11/23 6:44 下午
 **/
@Slf4j
@Service
public class AppSignServiceImpl implements AppSignService {
    /**
     * 注入-App-配置
     */
    @Autowired
    private AppConfig.AppProperty appProperty = null;

    @Override
    public String buildSign(@Nonnull final Map<String, Serializable> params) {
        final String appSecret = appProperty.getAppSecret();
        Assert.hasText(appSecret, "'appSecret'不能为空!");
        return SignUtils.buildSign(params, appSecret);
    }
}
